/**
 * 
 */
package com.bs.areport.service.master;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import net.spy.db.DBUtil;

import com.bs.areport.service.util.DataUtil;
import com.bs.areport.service.util.EntityType;
import com.bs.areport.service.util.MethodUtil;
import com.bs.areport.sys.*;
import com.bs.restframework.context.util.SystemContextUtil;
import com.bs.restframework.db.Database;
import com.bs.restframework.session.UserSession;
import com.bs.restframework.util.DesUtils;
import com.bs.restframework.util.GUID;
import com.bs.restframework.web.result.ResultModle;
import com.bs.restframework.web.result.ResultType;

/**
 * 
 * <p>函数名称：用户服务类</p>
 * <p>创建时间：2012-03-08</p>
 * <p>作者：李新宇</p>
 */
public class UserManageDao {
	
	/**
	 * 
	 * <p>函数名称：login</p>
	 * <p>功能说明：登录/p>
	 * <p>参数说明：</p>
	 * <p>创建时间：2012-03-08</p>
	 * <p>作者：李新宇</p>
	 */
	public Map<String, Object> login(String code,String pwd) throws Exception
	{	
		Database db = SystemContextUtil.getDatabase(this);
		Map loginInfo=new HashMap<String, Object>();
		List<Map> right=null;
		String msg="";
		
		Object[] params = new Object[] { code};
		String sql="SELECT U.F_ID,U.F_NAME,U.F_PASSWORD,U.F_STATE,U.F_USERTYPE,U.F_DEPTID,U.F_LASTTIME,D.F_CODE AS DEPTCODE,D.F_STATE AS DEPTSTATE,D.F_NAME AS DEPTNAME FROM "+EntityType.SYS_USER_TABLE+" U ";
		sql+=" LEFT JOIN "+EntityType.ARP_BSC_DEPT_TABLE+" D ON D.F_ID=U.F_DEPTID";
		sql+=" WHERE U.F_CODE=?";
		
		Map user=db.queryObject(Map.class, sql, params);
		
		if (user!=null&&user.size()>0){
			if(!user.get("F_PASSWORD").equals(DesUtils.encryptDSE(pwd)))
				msg="密码不正确!";
			else if("1".equals((String)user.get("F_STATE")))
				msg="该用户已被停用，请联系管理员!";
			else if("1".equals((String)user.get("DEPTSTATE")))
				msg="单位：["+(String)user.get("DEPTCODE")+"]"+(String)user.get("DEPTNAME")+"已被停用请联系管理员，请联系管理员!";
			else{
				right=getUserRight(db,(String)user.get("F_ID"),"");
			}
		}else {
			msg="用户名不正确!";
		}
	    
		loginInfo.put("user", user);
		loginInfo.put("msg", msg);
		loginInfo.put("right", right);
		return loginInfo;
	}

	/**
	 * 
	 * <p>函数名称：getUserRight</p>
	 * <p>功能说明：获取用户权限/p>
	 * <p>参数说明：userID: 用户ID ; userType: 用户类型</p>
	 * <p>创建时间：2012-03-08</p>
	 * <p>作者：李新宇</p>
	 */	
	public List<Map> getUserRight(Database db,String userID,String userType){
		
		String sql="SELECT * FROM SYS_RIGHT WHERE F_CODE IN (SELECT substr(R.F_CODE,0,3) FROM SYS_USERRIGHT U LEFT JOIN SYS_RIGHT R ON R.F_ID=U.F_RIGHTID WHERE R.F_ID IS NOT NULL AND U.F_USERID='"+userID+"') ";
		sql+=" OR F_CODE IN (SELECT R.F_CODE FROM SYS_USERRIGHT U LEFT JOIN SYS_RIGHT R ON R.F_ID=U.F_RIGHTID WHERE R.F_ID IS NOT NULL AND U.F_USERID='"+userID+"')";
		sql+=" ORDER BY F_CODE";
//		String sql="SELECT R.* FROM SYS_RIGHT R ORDER BY R.F_CODE";
		List<Map> rights=db.queryList(Map.class, sql, null);
		
		return rights;
	}
	
	
	/**
	 * 
	 * <p>函数名称：getMaxCode</p>
	 * <p>功能说明：获取最大编码值/p>
	 * <p>参数说明：deptCode: 单位编码 ; userID : 直管上级ID</p>
	 * <p>创建时间：2012-03-08</p>
	 * <p>作          者：李新宇</p>
	 * <p>修          改：陈金滨</p>
	 * <p>备注说明：用户编码默认为以用户所属单位编码开头，可更改</p>
	 */
	public Map<String, Object> getMaxCode(String deptCode,String deptID) throws Exception	
	{	
		
		Database db = SystemContextUtil.getDatabase(this);		
		String sql=" SELECT * FROM (SELECT * FROM "+EntityType.SYS_USER_TABLE ;
		sql += " WHERE F_CODE LIKE '"+deptCode+"%' AND F_DEPTID IS NOT NULL AND F_CODE<>'"+deptCode ;
		sql +=" ' AND F_HIGHTUP='"+deptID+"' ORDER BY TO_NUMBER(F_CODE) DESC ) WHERE rownum =1";
        Map<String, Object> vMap=db.queryObject(Map.class, sql, null);
		if(vMap==null||"".equals(vMap))
		{
		    vMap=new HashMap<String, Object>();
			vMap.put("F_CODE", deptCode+"000");
		}
		return vMap;
	}
	/**
	 * 
	 * <p>函数名称：qrylist</p>
	 * <p>功能说明：查询列表</p>
	 * <p>参数说明：objects：查询参数</p>
	 * <p>创建时间：2012-04-06</p>
	 * <p>作          者：陈金滨</p>
	 */
	public Map<String, Object> qrylist(Map<String, Object> objects) throws Exception
	{
		Database db = SystemContextUtil.getDatabase(this);
        Map<String, Object> resultMap=new HashMap<String, Object>();;
        
		String deptConditon="";
		
		//获取登陆用户信息
		String token =(String)objects.get("Token");
		UserSession userSession = SystemContextUtil.getSessionMange().getUserSession(token);
		String deptCode=(String)userSession.getAttribute("deptCode");
		String userID=(String)userSession.getUserID().toString();
		String userType = userSession.getUserType().toString();

		
		//传入查询参数
		String usercode=(String)objects.get("F_CODE");
		String username=(String)objects.get("F_NAME");
		String userQueryID=(String)objects.get("F_ID");
		
		String Condition = "" ;
		//如果传入编码不为空，按编码查询
		if(usercode!=null&&!"".equals(usercode))
		{
			deptConditon+=" AND USERINFO.F_CODE LIKE '"+usercode+"%' ";			
			Condition = Condition + " AND F_CODE LIKE '"+usercode+"%'" ;
		}
		
		//如果传入用户名不为空，关联用户名条件查询
		if(username!=null&&!"".equals(username))
		{
			deptConditon+=" AND USERINFO.F_NAME LIKE '%"+username+"%' ";
			Condition = Condition + " AND F_NAME LIKE '%"+username+"%'";			
		}
		
		//如果传入ID,则根据ID 查询
		if(userQueryID!=null&&!"".equals(userQueryID))
		{
			deptConditon+=" AND USERINFO.F_ID='"+userQueryID+"' ";
			Condition = Condition + " AND F_ID='"+userQueryID+"'";			
		}
		
		//过滤当前登陆用户，登陆用户不显示在人员管理中，A表示超级管理员
		if("A".equals(userType))
		{			
			deptConditon+=" AND USERINFO.F_USERTYPE<>'A'";
		}
		else
		{
			deptConditon += " AND USERINFO.F_HIGHTUP='"+userID+"' AND USERINFO.F_ID<>'"+userID+"'";
		}		
		
		int page = Integer.valueOf((String)objects.get("page"));
		int rows = Integer.valueOf((String)objects.get("rows"));
		
		String sql="SELECT USERINFO.*,USERGROUP.F_NAME AS GROUPNAME,DEPT.F_NAME AS DEPTNAME FROM "+EntityType.SYS_USER_TABLE + " USERINFO LEFT JOIN ";
		sql +=" SYS_USERGROUP USERGROUP ON USERINFO.F_USERGROUPID=USERGROUP.F_ID " ;
		sql +="	LEFT JOIN ARP_BSC_DEPT DEPT ON USERINFO.F_DEPTID=DEPT.F_ID " ;
		sql +=" WHERE 1=1 ";
		sql +=deptConditon;
		sql +=" ORDER BY TO_NUMBER(USERINFO.F_CODE)";
        Map<String, Object> counts=db.queryObject(Map.class, sql, null);
        List<Map> listCount = db.queryList(Map.class, sql,null);	
        int count = listCount.size();
		sql = Tools.formatPagingSQL(sql,rows,page);        
	    List<Map> listMap = db.queryList(Map.class, sql,null);				
		resultMap.put("rows", listMap);
		resultMap.put("total", count);
		return resultMap;        
	}	
	/**
	 * 
	 * <p>函数名称：list</p>
	 * <p>功能说明：查询列表</p>
	 * <p>参数说明：</p>
	 * <p>创建时间：2012-03-08</p>
	 * <p>作者：李新宇</p>
	 */
	public Map<String, Object> list(Map<String, Object> objects) throws Exception
	{
		Database db = SystemContextUtil.getDatabase(this);
        Map<String, Object> resultMap=new HashMap<String, Object>();;
        
		String deptConditon="";
		
		//获取用户单位信息
		String token =(String)objects.get("Token");
		UserSession userSession = SystemContextUtil.getSessionMange().getUserSession(token);
		String deptCode=(String)userSession.getAttribute("deptCode");
		String UserType = (String)userSession.getUserType().toString();
		String UserID=(String)userSession.getUserID().toString();
		String UserCode = this.getCodeByID(UserID);
		String DWJC = MethodUtil.getDeptJC(db);
		Integer Level = 0 ;
		//过滤当前登陆用户
		if("A".equals(UserType))
		{
			deptConditon+=" AND USERINFO.F_USERTYPE<>'A' ";
		}
		else
		{
			if(deptCode!=null&&!"".equals(deptCode))
			{
				Level = MethodUtil.getLevel(DWJC, deptCode);
				deptConditon+=" AND DEPT.F_CODE LIKE '"+deptCode+"%' ";
				deptConditon+=" AND ( DEPT.F_LEVEL='"+Level+"' OR ( DEPT.F_LEVEL='"+(Level+1)+"' AND USERINFO.F_USERTYPE<>'P')) " ;
			}
				
			deptConditon += " AND USERINFO.F_ID<>'"+UserID+"'";
//			deptConditon += " AND USERINFO.F_HIGHTUP='"+UserID+"' AND USERINFO.F_ID<>'"+UserID+"'";
		}
		
		int page = Integer.valueOf((String)objects.get("page"));
		int rows = Integer.valueOf((String)objects.get("rows"));
		
		String sql="SELECT USERINFO.*,USERGROUP.F_NAME AS GROUPNAME,DEPT.F_NAME AS DEPTNAME FROM "+EntityType.SYS_USER_TABLE + " USERINFO LEFT JOIN ";
		sql +=" SYS_USERGROUP USERGROUP ON USERINFO.F_USERGROUPID=USERGROUP.F_ID " ;
		sql +="	LEFT JOIN ARP_BSC_DEPT DEPT ON USERINFO.F_DEPTID=DEPT.F_ID " ;
		sql +=" WHERE 1=1 ";
		sql +=deptConditon;
		sql +=" ORDER BY USERINFO.F_CODE";
		List<Map> listCount = db.queryList(Map.class, sql,null);	
        Map<String, Object> counts=db.queryObject(Map.class, sql, null);
        int count = listCount.size();
		sql = Tools.formatPagingSQL(sql,rows,page);
        
	    List<Map> listMap = db.queryList(Map.class, sql,null);
	    
		resultMap.put("rows", listMap);
		resultMap.put("total", count);

		return resultMap;      
	}
	/**
	 * 
	 * <p>函数名称：getUserListCount</p>
	 * <p>功能说明：获取表记录数</p>
	 * <p>参数说明：db:数据源 ; valueMap:值列表  ; type: 数据对象类型</p>
	 * <p>创建时间：2012-03-07</p>
	 * <p>作者：李新宇</p>
	 */
	public int getUserListCount()throws Exception 
	{
		Database db = SystemContextUtil.getDatabase(this);
		String sql = "SELECT Count(*) FROM "+EntityType.SYS_USER_TABLE+" WHERE 1=1 ";
		int Count =db.queryObject(BigDecimal.class, sql).intValue();

		return Count;
	}
	/**
	 * 
	 * <p>函数名称：setPWD</p>
	 * <p>功能说明：设置密码</p>
	 * <p>参数说明：userID: 用户ID ;pwd :用户新密码;lastTime：最后修改时间</p>
	 * <p>创建时间：2012-04-07</p>
	 * <p>作者：陈金滨</p>
	 */
	public String setPWD(String userID,String pwd,String lastTime)throws Exception 
	{
		String msg = "";
		Database db = SystemContextUtil.getDatabase(this);
		if(userID!=null&&"".equals(userID)==false&&pwd!=null&&"".equals(pwd)==false)
		{
			pwd = DesUtils.encryptDSE(pwd);
			String sql = "UPDATE "+EntityType.SYS_USER_TABLE+" SET F_PASSWORD='"+pwd+"' WHERE F_ID='"+userID+"'";
			db.update(sql);	
			msg="修改密码成功!";
		}
		else
			msg="修改密码失败!";
		return msg;
	}	
	/**
	 * 
	 * <p>函数名称：getQryUserListCount</p>
	 * <p>功能说明：获取表记录数</p>
	 * <p>参数说明：Condition：查询条件</p>
	 * <p>创建时间：2012-04-06</p>
	 * <p>作者：陈金滨</p>
	 */
	public int getQryUserListCount(String Condition)throws Exception 
	{
		Database db = SystemContextUtil.getDatabase(this);
		String sql = "SELECT Count(*) FROM "+EntityType.SYS_USER_TABLE+" WHERE 1=1 "+Condition;
		int Count =db.queryObject(BigDecimal.class, sql).intValue();

		return Count;
	}	
	/**
	 * 
	 * <p>函数名称：getUserInfoByCode</p>
	 * <p>功能说明：通过用户编码获取用户信息</p>
	 * <p>参数说明：code ： 用户编码</p>
	 * <p>创建时间：2012-04-06</p>
	 * <p>作者：陈金滨</p>
	 */
	@SuppressWarnings("unchecked")
	public Map<String, Object> getUserInfoByCode(String code)throws Exception 
	{
		Database db = SystemContextUtil.getDatabase(this);
		String sql = "SELECT * FROM "+EntityType.SYS_USER_TABLE+" WHERE F_CODE='"+code+"'";
		Map<String, Object> vMap =db.queryObject(Map.class, sql);

		return vMap;
	}			
	/**
	 * 
	 * <p>函数名称：edit</p>
	 * <p>功能说明：编辑</p>
	 * <p>参数说明：</p>
	 * <p>创建时间：2012-03-08</p>
	 * <p>作者：李新宇</p>
	 */
	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
	public String edit(Map<String, Object> objects) throws Exception
	{
		String msg = "";

		Database db = SystemContextUtil.getDatabase(this);
		DataUtil.update(db, objects, EntityType.SYS_USER);
		
		//分配默认用户权限
		Date currentTime = new Date();
	    SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmsssss");
	    String dateString = formatter.format(currentTime);			    
		
        String userType = (String) objects.get("F_USERTYPE");
        String userCode = (String) objects.get("F_CODE");
        Map<String, Object> UserInfo = this.getUserInfoByCode(userCode);
        String loadUser = (String) objects.get("F_USER"); //当前登陆用户id
        if(UserInfo==null||"".equals(UserInfo))
        {
        	msg = "尚未分配默认权限,请手动修改!" ;
        }
        else
        {
        	if(userType.equals("G"))
        	{
            	String edtiUser = (String) UserInfo.get("F_ID") ;  //当前所修改的用户id
//            	Map<String, Object> valueMap = new HashMap<String, Object>();
            	//清除权限
            	if(edtiUser!=null||"".equals(edtiUser)==false)
            	{
	            	String sql = "DELETE FROM "+EntityType.SYS_USERRIGHT_TABLE+" WHERE F_USERID='"+edtiUser+"'" ;   
	            	db.update(sql) ;
            	}
            	//获取权限ID
            	String sql = "SELECT F_RIGHTID FROM "+EntityType.SYS_USERRIGHT_TABLE+" WHERE F_USERID='"+loadUser+"'" ;   

                List<Map> listMap = db.queryList(Map.class, sql,null);
                for(int i=0 ;i<listMap.size();i++)
                {
                	Map<String,Object> map = listMap.get(i);
                	Map<String,Object> rightMap = new HashMap<String,Object>();
                	rightMap.put("F_RIGHTID", map.get("F_RIGHTID"));
                	rightMap.put("F_USERID", edtiUser);
                	rightMap.put("F_LASTTIME", dateString);
                	DataUtil.add(db, rightMap, EntityType.SYS_USERRIGHT);	            	
                }
        	}
        	if(userType.equals("P"))
        	{
        		String edtiUser = (String) UserInfo.get("F_ID") ;
            	if(edtiUser!=null||"".equals(edtiUser)==false)
            	{
	            	String sql = "DELETE FROM "+EntityType.SYS_USERRIGHT_TABLE+" WHERE F_USERID='"+edtiUser+"'" ;   
	            	db.update(sql) ;
            	}
        	}

        }
		return msg;
	}
	/**
	 * 
	 * <p>函数名称：del</p>
	 * <p>功能说明：删除</p>
	 * <p>参数说明：</p>
	 * <p>创建时间：2012-03-08</p>
	 * <p>作者：李新宇</p>
	 */
	public String del(Map<String, Object> objects) throws Exception
	{
		String msg = "";
		Database db = SystemContextUtil.getDatabase(this);
		String userID = (String) objects.get("F_ID");
		String sql = "DELETE FROM "+EntityType.SYS_USERRIGHT_TABLE+" WHERE F_USERID='"+userID+"'" ;  
		db.update(sql);
        
		DataUtil.del(db, objects, EntityType.SYS_USER, false, false);
		
		return msg;
	}
	/**
	 * 
	 * <p>函数名称：isGmExist</p>
	 * <p>功能说明：判断某单位是否已经存在管理员</p>
	 * <p>参数说明：deptID:单位ID</p>
	 * <p>创建时间：2012-03-08</p>
	 * <p>作者：陈金滨</p>
	 */
	public boolean isGmExist(String deptID) throws Exception
	{
		boolean result = false;
		Database db = SystemContextUtil.getDatabase(this);
		
		String sql = "SELECT * FROM "+EntityType.SYS_USER_TABLE+" WHERE F_DEPTID='"+deptID+"' AND F_USERTYPE='G' AND F_STATE='0' " ;  
		Map<String, Object> vMap=db.queryObject(Map.class, sql, null);
		if((vMap==null)||(vMap.isEmpty()))
		{
			result = false ;
		}
		else
		{
			result = true ;
		}
		return result;
		
	}	
	/**
	 * 
	 * <p>函数名称：isGmExist</p>
	 * <p>功能说明：判断某单位是否已经存在管理员</p>
	 * <p>参数说明：deptID:单位ID,userID:用户id</p>
	 * <p>创建时间：2012-03-08</p>
	 * <p>作者：陈金滨</p>
	 */
	public boolean isGmExist(String deptID,String userID) throws Exception
	{
		boolean result = false;
		Database db = SystemContextUtil.getDatabase(this);
		
		String sql = "SELECT * FROM "+EntityType.SYS_USER_TABLE+" WHERE F_DEPTID='"+deptID+"' AND F_USERTYPE='G' AND F_STATE='0' AND F_ID<>'"+userID+"' " ;  
		Map<String, Object> vMap=db.queryObject(Map.class, sql, null);
		if((vMap==null)||(vMap.isEmpty()))
		{
			result = false ;
		}
		else
		{
			result = true ;
		}
		return result;
		
	}	
	/**
	 * 
	 * <p>函数名称：add</p>
	 * <p>功能说明：添加新</p>
	 * <p>参数说明：</p>
	 * <p>创建时间：2012-03-08</p>
	 * <p>作者：李新宇</p>
	 */
	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
	public String add(Map<String, Object> objects) throws Exception
	{
		String msg = "";

		Database db = SystemContextUtil.getDatabase(this);
        DataUtil.add(db, objects, EntityType.SYS_USER);
        
        //最后修改时间
        Date currentTime = new Date();
	    SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmsssss");
	    String dateString = formatter.format(currentTime);		
	    
        //分配默认用户权限
        String UserType = (String) objects.get("F_USERTYPE");
        String UserCode = (String) objects.get("F_CODE");
        Map<String, Object> UserInfo = this.getUserInfoByCode(UserCode);
        String User = (String) objects.get("F_USER");
        if(UserInfo==null||"".equals(UserInfo))
        {
        	msg = "尚未分配默认权限,请手动修改!" ;
        }
        else
        {
        	if(UserType.equals("G"))
        	{
            	String UserID = (String) UserInfo.get("F_ID") ;
            	Map<String, Object> ValueMap = new HashMap<String, Object>();
            	//获取权限ID
            	//2012-08-20   陈金滨   过滤基础设置权限
            	String sql = "SELECT F_RIGHTID FROM "+EntityType.SYS_USERRIGHT_TABLE+" WHERE F_USERID='"+User+"' AND F_RIGHTID<>'003' AND F_RIGHTID<>'003001' " ;   
                 List<Map> listMap = db.queryList(Map.class, sql,null);
                for(int i=0 ;i<listMap.size();i++)
                {
                	Map<String,Object> map = listMap.get(i);
                	Map<String,Object> RightMap = new HashMap<String,Object>();
                	RightMap.put("F_RIGHTID", map.get("F_RIGHTID"));
                	RightMap.put("F_USERID", UserID);
                	RightMap.put("F_LASTTIME", dateString);
                	DataUtil.add(db, RightMap, EntityType.SYS_USERRIGHT);	            	
                }
        	}

        }
		return msg;
	}
	/**
	 * 
	 * <p>函数名称：initPwd</p>
	 * <p>功能说明：初始化密码</p>
	 * <p>参数说明：</p>
	 * <p>创建时间：2012-03-28</p>
	 * <p>作者：陈金滨</p>
	 */
	public String initPwd(Map<String, Object> objects) throws Exception
	{
		String msg = "";

		Database db = SystemContextUtil.getDatabase(this);
		DataUtil.update(db, objects, EntityType.SYS_USER);

		return msg;
	}
	/**
	 * 
	 * <p>函数名称：isCodeExist</p>
	 * <p>功能说明：判断编码是否已经存在</p>
	 * <p>参数说明：code:编码</p>
	 * <p>创建时间：2012-03-26</p>
	 * <p>作者：陈金滨</p>
	 */
	
	public boolean isCodeExist(String code) throws Exception
	{	
		Database db = SystemContextUtil.getDatabase(this);
		boolean result=false ;
		String sql="SELECT * FROM "+EntityType.SYS_USER_TABLE+" WHERE F_CODE='"+code+"'";
        Map<String, Object> vMap=db.queryObject(Map.class, sql, null);
		if((vMap==null)||(vMap.isEmpty()))
		{
			result = false ;
		}
		else
		{
			result = true ;
		}
		return result;
	}	
	/**
	 * 
	 * <p>函数名称：getCodeByID</p>
	 * <p>功能说明：通过ID查找编码</p>
	 * <p>参数说明：id:ID</p>
	 * <p>创建时间：2012-03-26</p>
	 * <p>作者：陈金滨</p>
	 */
	public String getCodeByID(String id) throws Exception
	{	
		Database db = SystemContextUtil.getDatabase(this);
		String sql="SELECT F_CODE FROM "+EntityType.SYS_USER_TABLE+" WHERE F_ID='"+id+"'";
        Map<String, Object> vMap=db.queryObject(Map.class, sql, null);
        String code = "";
		if((vMap.isEmpty())||(vMap==null))
		{
			code = "" ;
		}
		else
		{
			code = (String) vMap.get("F_CODE");
		}
		return code;
	}	
	/**
	 * 
	 * <p>函数名称：getInfoByID</p>
	 * <p>功能说明：通过ID查找信息</p>
	 * <p>参数说明：id:ID</p>
	 * <p>创建时间：2012-03-26</p>
	 * <p>作者：陈金滨</p>
	 */
	public Map<String, Object>  getInfoByID(String id) throws Exception
	{	
		Database db = SystemContextUtil.getDatabase(this);
		String sql="SELECT * FROM "+EntityType.SYS_USER_TABLE+" WHERE F_ID='"+id+"'";
        Map<String, Object> vMap=db.queryObject(Map.class, sql, null);
		return vMap;
	}		
	/**
	 * 
	 * <p>函数名称：getPwdByID</p>
	 * <p>功能说明：取得原始密码</p>
	 * <p>参数说明：用户ID</p>
	 * <p>创建时间：2012-03-26</p>
	 * <p>作者：陈金滨</p>
	 */
	public String getPwdByID(String id) throws Exception
	{	
		Database db = SystemContextUtil.getDatabase(this);
		String sql="SELECT F_PASSWORD FROM "+EntityType.SYS_USER_TABLE+" WHERE F_ID='"+id+"'";
        Map<String, Object> vMap=db.queryObject(Map.class, sql, null);
        String result = "";
		if((vMap.isEmpty())||(vMap==null))
		{
			result = "" ;
		}
		else
		{
			result = (String) vMap.get("F_PASSWORD");
		}
		return result;
	}		
	
}
